package inet.app.vod.util;

import android.util.Log;

/**
 * Base thread for easy start, resume, pause and kill thread
 * @author thangdlv
 *
 */
public class BaseThread extends Thread {
	private final static String TAG = "BaseThread";
	protected boolean isLooping;
	protected boolean isRunning;

	/**
	 * start thead
	 */
	@Override
	public void start() {
		isLooping = true;
		isRunning = true;
		super.start();
		Log.d(TAG, "start");
	}

	/**
	 * resume thread
	 */
	public void onResume() {
		isRunning = true;
		Log.d(TAG, "start");
	}

	/**
	 * pause thread
	 */
	public void onPause() {
		isLooping = true;
		isRunning = false;
		Log.d(TAG, "pause");
	}

	/**
	 * kill thread
	 */
	public void kill() {
		isLooping = false;
		isRunning = false;

		try {
			join();
			Log.d(TAG, "kill");
		} catch (InterruptedException e) {
			e.printStackTrace();
			Log.d(TAG, "kill error");
		}
	}
}

		